import 'package:flutter/material.dart';
import 'package:flutter_architecture_samples_vanilla/models.dart';
import 'package:todos_app_core/todos_app_core.dart';

class ExtraActionsButton extends StatelessWidget {
  final PopupMenuItemSelected<ExtraAction> onSelected;
  final bool allComplete;
  final bool hasCompletedTodos;

  const ExtraActionsButton(
      {Key? key,
      required this.onSelected,
      required this.allComplete,
      required this.hasCompletedTodos})
      : super(key: key);
  @override
  Widget build(BuildContext context) {
    return PopupMenuButton<ExtraAction>(
        key: ArchSampleKeys.extraActionsButton,
        onSelected: onSelected,
        itemBuilder: (BuildContext context) => <PopupMenuItem<ExtraAction>>[
              PopupMenuItem<ExtraAction>(
                key: ArchSampleKeys.toggleAll,
                value: ExtraAction.toggleAllComplete,
                child: Text(allComplete
                    ? ArchSampleLocalizations.of(context)!.markAllIncomplete
                    : ArchSampleLocalizations.of(context)!.markAllComplete),
              ),
              PopupMenuItem<ExtraAction>(
                key: ArchSampleKeys.inverseCompleted,
                value: ExtraAction.inverseCompleted,
                child: Text('反选'),
              ),
              PopupMenuItem<ExtraAction>(
                key: ArchSampleKeys.clearCompleted,
                value: ExtraAction.clearCompleted,
                child:
                    Text(ArchSampleLocalizations.of(context)!.clearCompleted),
              ),
            ]);
  }
}
